<?php
namespace app\admin\validate;

use think\Validate;

class Template extends Validate
{
    protected $rule = [
        'name'     => 'require|length:2,50',
        'content'  => 'require',
        'type'     => 'require|number|in:1,2,3',
        'status'   => 'require|in:0,1'
    ];

    protected $message = [
        'name.require'     => '模板名称不能为空',
        'name.length'      => '模板名称长度必须在2-50个字符之间',
        'content.require'  => '模板内容不能为空',
        'type.require'     => '模板类型不能为空',
        'type.number'      => '模板类型必须是数字',
        'type.in'          => '模板类型不正确',
        'status.require'   => '状态不能为空',
        'status.in'        => '状态值不正确'
    ];

    protected $scene = [
        'add'  => ['name', 'content', 'type', 'status'],
        'edit' => ['name', 'content', 'type', 'status']
    ];
}